<?php

namespace app\api\controller;

use app\common\business\user\Device as deviceBn;

class Device extends \app\common\controller\HomeBase {

    /**
     * 增加设备信息
     * `ip` varchar(50) DEFAULT NULL, 
     * app_version
     * sysversion
     * sysname
     * device_type IOS，安卓
     * client_id 个推送
     * uuid 唯一
     */
    public function add() {
        try {
            $user_id =$this->_isLogin();
            $post = input();
            $params = $this->validate($post, 'Device.add');
            $params['user_id'] = $user_id;
            $bn = new deviceBn();
            $data = $bn->add($params);
            $this->_echoSuccessMessage('', true);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }
    /**
     时间分布
     */
    public function timeschart() {
        try {

            $data=deviceBn::timeschart();
            $this->_echoSuccessMessage('', $data);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }
    /**
      平台分布
     */
    public function systemchart() {
        try {

            $data=deviceBn::systemchart();
            $this->_echoSuccessMessage('', $data);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }
    /**
     省份
     */
    public function provincechart() {
        try {

            $data=deviceBn::provincechart();
            $this->_echoSuccessMessage('', $data);
        } catch (\Exception $e) {
            $this->_echoErrorMessage($e->getMessage(), $e->getCode());
        }
    }
}
